package com.example.sw.myapp0928;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Switch;
import android.widget.TextView;

import androidx.annotation.NonNull;

        import com.example.sw.myapp0928.Bean.AlamItem;

        import java.util.List;

public class NaoZhongAdapter extends ArrayAdapter<AlamItem> {

    private  int rid;

    public NaoZhongAdapter(@NonNull Context context, int resource, @NonNull List<AlamItem> objects) {
        super(context, resource, objects);
        rid = resource;

    }

    @Override
    public  View getView(int i,View view,ViewGroup parent){
        //指定布局
        View v= LayoutInflater.from(getContext()).inflate(rid,null);
        //控件实例化
        TextView txtTime=v.findViewById(R.id.txtTime);
        Switch swbtn= v.findViewById(R.id.swbtn);
        //数据填充布局
        AlamItem a=getItem(i);
        txtTime.setText(a.getTime());
        swbtn.setChecked(a.isIschecked());
        //返回V
        return v;


    }
}

